﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication5.Controller;
namespace WebApplication5.Pages
{

    public partial class login : System.Web.UI.Page
    {
        personCtr pCtr = new personCtr();
        protected void Page_Load(object sender, EventArgs e)
        {
            Site1 s = Page.Master as Site1;
            s.SelectedMenu = "login";


            string logout = Request.QueryString["Logout"] ?? "false";
            if (logout == "true")
            {
                Session.Clear();
                Response.Redirect("/default.aspx");
            }
        }

        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            Model.Login l = pCtr.GetPerson(UsernameTbe.Text, PasswordTbe.Text);

            if (l != null)
            {
                Session["Login"] = l;
                Response.Redirect("/default.aspx");
            }
            else
            {
                string myStringVariable = "forkert brugernavn eller kodeord";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
            }

        }

    }
}